package research.ui.editors;

import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

import research.entity.Entity;
import research.ui.editors.input.EntityEditorInput;

public class EditorFactory {

	public static void openEditor(Entity entity) {
		if (entity == null)
			return;
		
		String editorId = entity.getType().getEditorId();
		if (editorId != null) {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
						.openEditor(new EntityEditorInput(entity), editorId);
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
	}
}
